<?php

class dangky extends CI_Controller 
{

	function __construct()
	{
		parent::__construct();
		$this->load->model('dangky_model','dangky');
	}
	
	function index()
	{
		$data['title'] = "" ;
		$data['page'] = 'dangky' ;
		$this->load->view('dangky',$data) ;
	}
	
	function action()
	{
		if($_POST['bt_submit'])
		{
			$this->form_validation->set_rules('username','Tên đăng nhập','trim|required');
			$this->form_validation->set_rules('password','Mật khẩu','trim|required');
			$this->form_validation->set_rules('cfpass','Xác nhận','trim|required');
			$this->form_validation->set_rules('email','email','trim|required');
			if($this->form_validation->run() == FALSE)
			{
				$this->pre_message = validation_errors();
			}
			else
			{
				$rs = $this->dangky->check_name();
				if(empty($rs)){
					if($this->dangky->save()){
						echo 1 ;
					}else{
						echo -1 ;
					}
				}
			}
		}
	}
	
	function thanhcong()
	{
		$data['title'] = "" ;
		$this->load->view('thanhcong',$data) ;
	}
}

?>